home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / RESDMP11 / TESTBOX.PAS < prev   
Pascal/Delphi Source File  |  1993-07-27  |  3KB  |  119 lines

  1. {$A+,B-,D+,E+,F+,G-,I+,L+,N-,O-,R+,S+,V+,X-}
  2. {$M 16384,0,655360}
  3. {use this as a template to test new dialog boxes}
  4.  
  5. program testbox;
  6.   uses Objects,Drivers,Views,Menus,Dialogs,App,Gadgets;
  7.  
  8.   const
  9.     cmAboutDialog = 101;
  10.     cmTestDialog  = 102;
  11.  
  12.   type
  13.  
  14.     TMyApp = object(TApplication)
  15.       Heap: PHeapView;
  16.       constructor init;
  17.       procedure HandleEvent(var Event: TEvent); virtual;
  18.       procedure InitMenuBar; virtual;
  19.       procedure InitStatusLine; virtual;
  20.       procedure AboutDialog;
  21.       procedure TestDialog;
  22.       procedure Idle;virtual;
  23.     end;
  24.  
  25.  
  26. VAR    RezFile: TResourceFile;
  27.        RezStream: PStream;
  28.  
  29.  
  30. CONSTRUCTOR TMyApp.Init;
  31.   VAR R : TRect;
  32.   BEGIN
  33.     RegisterObjects;
  34.     RegisterViews;
  35.     RegisterMenus;
  36.     RegisterDialogs;
  37.     RegisterApp;
  38.     RegisterType(RStringList);
  39.  
  40.     RezStream := New(PBufStream, Init('TESTBOX.BRS', stOpenRead, 4096));
  41.     RezFile.Init(RezStream);
  42.     TApplication.Init;
  43.  
  44.     GetExtent(R);
  45.     Dec(R.B.X);
  46.     R.A.X := R.B.X - 9; R.A.Y := R.B.Y - 1;
  47.     Heap := New(PHeapView, Init(R));
  48.     Insert(Heap);
  49.  
  50.   END;
  51.  
  52.  
  53.   procedure TMyApp.HandleEvent(var Event: TEvent);
  54.  
  55.     begin {HandleEvent}
  56.  
  57.       TApplication.HandleEvent(Event);
  58.       if (Event.What = evCommand) then
  59.          begin
  60.            case Event.Command of
  61.             cmAboutDialog :
  62.                AboutDialog;
  63.             cmTestDialog :
  64.                TestDialog;
  65.             else
  66.                Exit;
  67.            end;
  68.            ClearEvent(Event);
  69.          end
  70.  
  71.     end;  {HandleEvent}
  72.  
  73. PROCEDURE TMyApp.Idle;
  74.   BEGIN
  75.     TApplication.Idle;
  76.     Heap^.Update;
  77.   END;{PROC TMyApp.Idle}
  78.  
  79.   procedure TMyApp.InitMenuBar;
  80.     begin {InitMenuBar}
  81.       MenuBar := PMenuBar(RezFile.Get('MAIN_MB'));
  82.     end;  {InitMenuBar}
  83.  
  84.  
  85.   procedure TMyApp.InitStatusLine;
  86.     begin  {InitStatusLine}
  87.       StatusLine := PStatusline(RezFile.Get('MAIN_ST'));
  88.     end; {InitStatusLine}
  89.  
  90.  
  91.   procedure TMyApp.AboutDialog;
  92.     var  Dialog : PDialog;
  93.          R      : TRect;
  94.          C      : word;
  95.     begin {AboutDialog}
  96.       Dialog := PDialog(RezFile.Get('ABOUT_DB'));
  97.       C := DeskTop^.ExecView(Dialog);
  98.       Dispose(Dialog,Done)
  99.     end;  {AboutDialog}
  100.  
  101.   procedure TMyApp.TestDialog;
  102.     var  Dialog : PDialog;
  103.          C      : word;
  104.     begin {AboutDialog}
  105.       Dialog := PDialog(RezFile.Get('TESTER_DB'));
  106.       C := DeskTop^.ExecView(Dialog);
  107.       Dispose(Dialog,Done)
  108.     end;  {TestDialog}
  109.  
  110.   var
  111.     MyApp : TMyApp;
  112.  
  113.  
  114.   begin {TESTBOX}
  115.     MyApp.Init;
  116.     MyApp.Run;
  117.     MyApp.Done;
  118.   end.  {TESTBOX}
  119.